package peace.transport.xmlrpc
{


/**
 * 
<methodResponse>
  <params>
    <param>
        <value><string>South Dakota</string></value>
    </param>
  </params>
</methodResponse>
 * 
 * 
 <methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><int>4</int></value>
        </member>
        <member>
          <name>faultString</name>
          <value><string>Too many parameters.</string></value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>
* 
 * 
 */	
	
	
public class XmlrpcResponse
{
	public var parameters:Array = [];
	
	public var hasError:Boolean = false;
	public var errorString:String = "";
	
	public function XmlrpcResponse (xml:XML)
	{
		parse (xml);
	}
	
	private function parse (xml:XML):void
	{
		var first:XML = xml.*[0];
		if (first.name()=="fault")
		{
			hasError = true;
			errorString = first.value.struct.member.(name=="faultString").value.string;
		}
		else
		{
			hasError = false;
			for each (var node:XML in first.param.value.*)
			{
				parameters.push( Xmlrpc.decodeValue(node));
			}
		}
	}

}
}